#include "Transformation.h"

int Transformation::mTransformCount=TRANSFORM_MAGIC_NO;

Transformation::Transformation(){
	char *mName= new char[128];
	mName="dummy";
	mID=Transformation::mTransformCount++;
	mJoint=NULL;
	mVariable=true;
	mModelID=-1;
	mTransform = new Mat4d(vl_0);
	mInvTransform = new Mat4d(vl_0);
	mDeriv = new Mat4d(vl_0);
}

bool Transformation::isPresent(Dof *d){
	for(int i=0; i<mDofs.size(); i++){
		if(d->getID()==mDofs[i]->getID()) return true;
	}
	return false;
}

void Transformation::applyTransformMat(Vec4d *v){
	Mat4d *m = getTransformMat();
	*v = (*m)*(*v);
}

void Transformation::applyTransformMat(Mat4d *m){
	Mat4d *mat = getTransformMat();
	*m = (*mat)*(*m);
}

void Transformation::applyInvTransformMat(Mat4d *m){
	Mat4d *mat = getInvTransformMat();
	*m = (*mat)*(*m);
}

void Transformation::applyDerivativeMat(Dof *d, Vec4d *v){
	Mat4d *m = getDerivativeMat(d);
	*v = (*m)*(*v);
}

void Transformation::applyDerivativeMat(Dof *d, Mat4d *m){
	Mat4d *mat = getDerivativeMat(d);
	*m = (*mat)*(*m);
}

void Transformation::applyDerivativeMat(Dof *d1, Dof *d2, Vec4d *v){
	Mat4d *mat = getDerivativeMat(d1, d2);
	*v = (*mat)*(*v);
}

void Transformation::applyDerivativeMat(Dof *d1, Dof *d2, Mat4d *v){
	Mat4d *mat = getDerivativeMat(d1, d2);
	*v = (*mat)*(*v);
}
